<template>
  <div class="execution">
    <basic-container>
      <div class="table-container">
        <el-table
          border
          :header-cell-style="{ color: '#4D4D4D', background: '#fafafa' }"
          :data="list"
        >
          <el-table-column label="商品名称">
            <template slot-scope="scope">
              <img
                :src="scope.row.pic"
                style="width: 50px; height: 50px; margin-right: 10px"
              />
              <span
                style="
                  position: absolute;
                  top: 50%;
                  transform: translateY(-50%);
                "
                >{{ scope.row.title }}</span
              >
            </template>
          </el-table-column>
          <el-table-column label="商品分类" align="center">
            <template slot-scope="scope">{{ scope.row.productType }}</template>
          </el-table-column>
          <el-table-column label="商品价格" align="center">
            <template slot-scope="scope">{{ scope.row.price }}</template>
          </el-table-column>
          <el-table-column label="商品状态" align="center">
            <template slot-scope="scope">{{
              scope.row.status | statusFilter
            }}</template>
          </el-table-column>
        </el-table>
      </div>
      <div class="pagination-container">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          layout="total, sizes,prev, pager, next,jumper"
          :page-size="listQuery.size"
          :page-sizes="[5, 10, 15]"
          :current-page.sync="listQuery.current"
          :total="total"
        >
        </el-pagination>
      </div>
    </basic-container>
  </div>
</template>
<script>
import "@/styles/index.scss";
import { lookFreight } from "@/api/pms/index";

export default {
  data() {
    return {
      list: [],
      listQuery: {
        current: 1,
        size: 10,
        id: this.$route.query.id,
      },
      total: 0,
    };
  },
  created() {
    this.getList();
  },
  filters: {
    statusFilter(value) {
      if (value === 1) {
        return "已上架";
      } else if (value === 2) {
        return "已上架";
      } else if (value === 3) {
        return "待审核";
      } else if (value === 4) {
        return "已驳回";
      }
    },
  },
  methods: {
    getList() {
      lookFreight(this.listQuery).then((res) => {
        this.list = res.data.data.records;
        this.total = res.data.data.total;
      });
    },
    handleSizeChange(val) {
      this.passListQuery.size = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.passListQuery.current = val;
      this.getList();
    },
  },
};
</script>